#!usr/bin/node

const jsdom = require("jsdom");
const {JSDOM} = jsdom;

const htmlFileName = process.argv[2];
const htmlFIlePath = __dirname+"/"+htmlFileName;

try{
  JSDOM.fromFile(htmlFIlePath).then(dom=>{

    let divNode = dom.window.document.querySelector(".con");
    let content = dom.window.document.querySelector(".con").textContent;
    let pNode = dom.window.document.createElement("p");
    let pContent = dom.window.document.createTextNode(content);

    pNode.appendChild(pContent);

    pNode.setAttribute("class","list");

    dom.window.document.querySelector("body").replaceChild(pNode,divNode);
  
    console.log(dom.serialize());
  });

}catch(err) {
  console.log(err);
}
